<template>
  <div>{{ msg }}登录成功！您的登录密码是：{{ psw }}</div>
</template>
<script>
  export default {
    data() {
      return {
        msg: "",
        psw: "",
      };
    },
    // 生命周期 钩子函数(它不是我们自己触发的，是浏览器帮我们触发的)，像钩子一样勾住了浏览器，浏览器渲染这个页面的时候，会自动执行
    created() {
      //success页面刚创建渲染成功后就会触发
      console.log(this.$route);
      if (this.$route.params.account!=undefined) {
        this.msg = this.$route.params.account;
        this.psw = this.$route.params.password;
      } else {
        this.msg = this.$route.query.account;
        this.psw = this.$route.query.password;
      }
    },
    watch: {
      $route: function (newV, oldV) {
        console.log(newV.params.account);
        if (newV.params.account!=undefined) {
          this.msg = newV.params.account;
          this.psw = newV.params.password;
        } else {
          this.msg = newV.query.account;
          this.psw = newV.query.password;
        }
      },
    },
  };
</script>